import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, JoinColumn, OneToOne } from 'typeorm';
import { ClassEntity } from './class.entity';
import { StudentWristband } from './student_wristband.entity';

@Entity('student')
export class Student {
  @PrimaryGeneratedColumn('increment')
  id: number;

  @ManyToOne(() => ClassEntity, { onDelete: 'NO ACTION', onUpdate: 'NO ACTION' })
  @JoinColumn({ name: 'class_id' })
  class: ClassEntity;

  @Column({ type: 'varchar', length: 15, default: '' })
  name: string;


  // 确保添加缺失的字段
  @Column({ type: 'varchar', length: 100, default: '' })
  s_number: string;  // 推荐使用驼峰命名


  @OneToOne(() => StudentWristband)
  @JoinColumn({ name: 'id', referencedColumnName: 'sid' })
  student_wristband: StudentWristband;
}
